<template>
    <div>
        用户名 <input type="text" v-model="username"/>
        密码: <input  type="text" v-model="password"/>
        <button @click="registry">注册</button>
    </div>
</template>

<script>
export default {
    data(){
        return {
            username:'',
            password:''
        }
    },
    methods:{
        registry(){
            if(this.username && this.password){
                this.$http.post('/api/registry',{username:this.username,password:this.password}).then(res => {
                    if(res.data.code === 1){
                        alert("注册成功")
                        //注册成功
                        this.$router.replace('/login');
                    }
                })
            }else{
                alert("参数有误")
            }
        }
    }
}
</script>